﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ForumsBrowser.ObjectGateway;
using System.Globalization;
using ForumsBrowser.Common;

namespace ForumsBrowser
{
    /// <summary>
    /// Interaction logic for UserSettings.xaml
    /// </summary>
    public partial class UserSettings : UserControl
    {
        public CultureInfo SelectedCulture = Configuration.Culture;
        public bool IsMiniViewEnabled = Configuration.IsMiniViewEnabled;
        public int MiniViewMinHeight = Configuration.MiniViewMinHeight;
        public int MaxPopupsCount = Configuration.MaxPopupsCount;

        public event EventHandler Done;
        public event EventHandler Cancel;

        public UserSettings()
        {
            InitializeComponent();
        }

        private void OKClick(object sender, RoutedEventArgs e)
        {
            SelectedCulture = culture.SelectedCulture;
            IsMiniViewEnabled = minibrowsersettings.IsMiniViewEnabled;
            MiniViewMinHeight = minibrowsersettings.MiniViewMinHeight;
            MaxPopupsCount = toasterpopupsettings.MaxPopupsCount;

            var handler = Done;
            if (handler != null)
                handler(this, EventArgs.Empty);
        }

        private void CancelClick(object sender, RoutedEventArgs e)
        {
            SelectedCulture = Configuration.Culture;
            IsMiniViewEnabled = Configuration.IsMiniViewEnabled;
            MiniViewMinHeight = Configuration.MiniViewMinHeight;
            MaxPopupsCount = Configuration.MaxPopupsCount;

            var handler = Cancel;
            if (handler != null)
                handler(this, EventArgs.Empty);
        }
    }
}
